<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/5/22 0022
  Time: 15:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!-- Job List Start -->
<c:forEach items="${pageInfo.list}" var="companyHrReceiveResume">
    <a class="job-list">
        <div class="company-logo col-auto">
            <img src="<%=path%>/assets/images/companies/company-1.png" alt="Company Logo">
        </div>
        <div class="salary-type col-auto order-sm-3">
            <div class="btns">
                <button type="button" onclick="window.location.href='<%=path%>/web/company/manage/resume/info?id=${companyHrReceiveResume.id}'"  class="badge badge-info">查看</button>
                <button type="button" id="mybtn" data-id="${companyHrReceiveResume.id}" data-name="cancel" class="badge badge-danger">删除</button>
            </div>
        </div>
        <div class="content col">
            <h6 class="title">${companyHrReceiveResume.resume.person.name}</h6>
            <ul class="meta">
                <li><strong class="text-primary">学历：</strong></li>
                <li>${companyHrReceiveResume.resume.educationExp.educationalBackgroundType.educationalBackgroundTypeName}</li>
                <li><strong class="text-primary">学校：</strong></li>
                <li>${companyHrReceiveResume.resume.educationExp.school.schoolName}</li>
                <li><strong class="text-primary">专业：</strong></li>
                <li>${companyHrReceiveResume.resume.educationExp.professionalName}</li>
                <li><strong class="text-primary">手机号：</strong></li>
                <li>${companyHrReceiveResume.resume.person.phone}</li>
                <li><strong class="text-primary">岗位名称：</strong></li>
                <li>${companyHrReceiveResume.companyPosition.name}</li>
            </ul>
        </div>
    </a>
</c:forEach>
<!-- Job List Start -->
<!-- Pagination Start -->
<ul class="pagination pagination-center mt-5">

    <li class="page-item"><a class="page-link" id="prePage" data-id="${pageInfo.pageNum-1}"><i class="fa fa-angle-left"></i></a></li>

    <c:if test="${pageInfo.pages>=5}">
        <c:if test="${pageInfo.pageNum>=3 && pageInfo.pageNum<=pageInfo.pages-2}">
            <c:forEach begin="${pageInfo.pageNum-2}" end="${pageInfo.pageNum+2}" var="stat">
                <c:if test="${stat eq pageInfo.pageNum}">
                    <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                </c:if>
                <c:if test="${stat ne pageInfo.pageNum}">
                    <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                </c:if>
            </c:forEach>
        </c:if>
        <c:if test="${pageInfo.pageNum<3}">
            <c:forEach begin="1" end="5" var="stat">
                <c:if test="${stat eq pageInfo.pageNum}">
                    <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                </c:if>
                <c:if test="${stat ne pageInfo.pageNum}">
                    <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                </c:if>
            </c:forEach>
        </c:if>
        <c:if test="${pageInfo.pageNum>pageInfo.pages-2}">
            <c:forEach begin="${pageInfo.pages-4}" end="${pageInfo.pages}" var="stat">
                <c:if test="${stat eq pageInfo.pageNum}">
                    <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                </c:if>
                <c:if test="${stat ne pageInfo.pageNum}">
                    <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                </c:if>
            </c:forEach>
        </c:if>
    </c:if>
    <c:if test="${pageInfo.pages<5}">
        <c:forEach begin="1" end="${pageInfo.pages}" var="stat">
            <c:if test="${stat eq pageInfo.pageNum}">
                <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
            </c:if>
            <c:if test="${stat ne pageInfo.pageNum}">
                <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
            </c:if>
        </c:forEach>
    </c:if>

    <li class="page-item"><a class="page-link" id="nextPage" data-id="${pageInfo.pageNum+1}"><i class="fa fa-angle-right"></i></a></li>

</ul>
<!-- Pagination End -->

<script type="text/javascript" src="<%=path%>/assets/js/vendor/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
    $(function () {
        $.each($("a[id^=page]"),function () {
            $(this).on("click",$(".job-list-wrap"),function () {
                var pageNum = $(this).attr("data-id");
                $.ajax({
                    url:"<%=path%>/web/company/manage/resume/listData",
                    type:"post",
                    data:"pageNum="+pageNum,
                    async:"false",
                    success:function (data) {
                        $(".job-list-wrap").html(data);
                    }
                });
            })
        });
        $("#prePage").on("click",$(".job-list-wrap"),function () {
            var pageNum = $("#prePage").attr("data-id");
            if(pageNum<=0){
                pageNum = 1;
            }
            $.ajax({
                url:"<%=path%>/web/company/manage/resume/listData",
                type:"post",
                data:"pageNum="+pageNum,
                async:"false",
                success:function (data) {
                    $(".job-list-wrap").html(data);
                }
            });
        });
        $("#nextPage").on("click",$(".job-list-wrap"),function () {
            var pageNum = $("#nextPage").attr("data-id");
            if(pageNum>${pageInfo.pages}){
                pageNum = ${pageInfo.pages};
            }
            $.ajax({
                url:"<%=path%>/web/company/manage/resume/listData",
                type:"post",
                data:"pageNum="+pageNum,
                async:"false",
                success:function (data) {
                    $(".job-list-wrap").html(data);
                }
            });
        });
        var button = $("button[id=mybtn]");
        $.each(button,function () {
            $(this).click(function () {
                var ts = $(this);
                var data_id = ts.attr("data-id");
                var flag = confirm("确定删除么");
                if(flag==false){
                    return;
                }

                //删除简历
                $.ajax({
                    url:"<%=path%>/web/company/manage/resume/delete",
                    data:"id="+data_id
                });
                ts.parent().parent().parent().remove();
            });
        });
    });
</script>